<?php

    require_once 'form/decorator/HTMLFormDecorator.php';

    $this->setVar('pageTitle', 'Form example');

    // In this case we've extended the Form. You could also create the form on
    // the fly:
    // $this->getForm()->addElement('myElement') etc.
    $formExample = new ExampleForm();
    $formExample->setDecorator(new HTMLFormDecorator());

    if ($request->isPost()) {
        // Setting the data to the form will apply any filters specified in the
        // form.
        $formExample->setData($request->getPost());

        // As the form isn't validated before, a call to the isValid method will
        // automaticly validate the form.
        if ($formExample->isValid()) {
            $formMessage = 'The form example is valid.';
        } else {
            $formMessage = 'The form example is NOT valid.';
        }
    }
?>
<h1>Form example</h1>
<p>Check out the source code in src/views/examples/form.php.</p>
<?php if (isset($formMessage)): ?>
<p><?php echo $formMessage; ?></p>
<?php endif; ?>
<?php echo $formExample->toString(); ?>